////////////////////////////////////////////////
// MACHINE GENERATED, PLEASE DONOT MODIFY!
////////////////////////////////////////////////

#include "../../plugin/protocol/protocol_register.hh"
#include "../common/generated_message_id_defines.hh"
#include "../common/generated_proto_header.hh"
#include "generated_message_handler_register.hh"

Message * ProtocolRegister::getMessage(std::uint32_t msgID) {
    auto it = msgMap_.find(msgID);
    if (it == msgMap_.end()) {
        return nullptr;
    }
    return it->second;
}

std::uint32_t ProtocolRegister::getMessageID(const Message & msg) {
    auto address = reinterpret_cast<ptrdiff_t>(msg.GetDescriptor());
    auto it = typeMap_.find(address);
    if (it == typeMap_.end()) {
        return 0;
    }
    return it->second;
}

const std::string & ProtocolRegister::getError() const {
    return error_;
}

MsgHandler * ProtocolRegister::getHandler(std::uint32_t msgID) {
    auto it = handlerMap_.find(msgID);
    if (it == handlerMap_.end()) {
        return nullptr;
    }
    return it->second;
}

bool ProtocolRegister::doRegister() {
    REGISTER_MESSAGE_PROTOTYPE(DummyEntityReq,DUMMYENTITYREQ)
    REGISTER_MESSAGE_PROTOTYPE(SceneLeaveReq,SCENELEAVEREQ)
    REGISTER_MESSAGE_PROTOTYPE(DummyReq,DUMMYREQ)
    REGISTER_MESSAGE_PROTOTYPE(PingReq,PINGREQ)
    REGISTER_MESSAGE_PROTOTYPE(SceneEnterReq,SCENEENTERREQ)
    REGISTER_MESSAGE_PROTOTYPE(SceneEnterNtf,SCENEENTERNTF)
    REGISTER_MESSAGE_PROTOTYPE(EnterReq,ENTERREQ)
    REGISTER_MESSAGE_PROTOTYPE(SceneEnterAck,SCENEENTERACK)
    REGISTER_MESSAGE_PROTOTYPE(RoleEnterNtf,ROLEENTERNTF)
    REGISTER_MESSAGE_PROTOTYPE(SceneLeaveAck,SCENELEAVEACK)
    REGISTER_MESSAGE_PROTOTYPE(RoleMoveNtf,ROLEMOVENTF)
    REGISTER_MESSAGE_PROTOTYPE(SceneMoveNtf,SCENEMOVENTF)
    REGISTER_MESSAGE_PROTOTYPE(SceneLeaveNtf,SCENELEAVENTF)
    REGISTER_MESSAGE_PROTOTYPE(ClientMoveNtf,CLIENTMOVENTF)
    REGISTER_MESSAGE_PROTOTYPE(LoginReq,LOGINREQ)
    REGISTER_MESSAGE_PROTOTYPE(EchoReq,ECHOREQ)
    REGISTER_MESSAGE_PROTOTYPE(RoleLeaveNtf,ROLELEAVENTF)
    REGISTER_MESSAGE_PROTOTYPE(AddBuffNtf,ADDBUFFNTF)
    REGISTER_MESSAGE(DummyEntityAck,DUMMYENTITYACK)
    REGISTER_MESSAGE(LoginAck,LOGINACK)
    REGISTER_MESSAGE(EchoAck,ECHOACK)
    REGISTER_MESSAGE(EnterAck,ENTERACK)
    REGISTER_MESSAGE(EnterNtf,ENTERNTF)
    REGISTER_MESSAGE(LeaveNtf,LEAVENTF)
    REGISTER_MESSAGE(MoveNtf,MOVENTF)
    REGISTER_MESSAGE(PingAck,PINGACK)
    REGISTER_MSG_HANDLER(DummyEntityAck)
    REGISTER_MSG_HANDLER(LoginAck)
    REGISTER_MSG_HANDLER(EchoAck)
    REGISTER_MSG_HANDLER(EnterAck)
    REGISTER_MSG_HANDLER(EnterNtf)
    REGISTER_MSG_HANDLER(LeaveNtf)
    REGISTER_MSG_HANDLER(MoveNtf)
    REGISTER_MSG_HANDLER(PingAck)
    return true;
}
